package com.lechuang.user.controller;


import com.lechuang.common.result.Result;
import com.lechuang.user.dto.RegisterByPhoneDto;
import com.lechuang.user.dto.UpdateUserDto;
import com.lechuang.user.manager.UserManager;
import com.lechuang.user.vo.UserDetailVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/userManage")
@Log4j2
@Tag(name = "用户管理类")
public class UserManagementController {

    @Resource
    private UserManager userManager;

    @Operation(summary = "根据手机号查询用户信息-f")
    @PostMapping("/queryUserDetailByPhone" )
    public Result<UserDetailVo> queryUserDetailByPhone(@RequestBody String  phone){
        log.info("手机号查询用户信息------{}",phone);
        UserDetailVo userActiveDto = userManager.queryUserDetailByPhone(phone);
        return Result.success(userActiveDto);
    }

    @Operation(summary = "修改资料-f")
    @PostMapping("/updateUser" )
    public Result updateUser(@RequestBody UpdateUserDto updateUserDto){
        log.info("修改资料------{}",updateUserDto);
        userManager.updateUser(updateUserDto);
        return Result.success();
    }


    @Operation(summary = "根据手机号进行注册")
    @PostMapping("/registerByPhone" )
    public Result registerByPhone(@RequestBody RegisterByPhoneDto registerByPhoneDto){
        log.info("根据手机号注册用户------{}",registerByPhoneDto);
        userManager.registerByPhone(registerByPhoneDto);
        return Result.success();
    }



}
